package com.lonely.controller;

import com.lonely.entity.bash.Result;
import com.lonely.entity.po.PaymentPo;
import com.lonely.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @date: 2021-11-02 11:35
 * @author: ztkj-hzb
 * @description: 支付模块
 **/
@RestController
@RequestMapping("/payment")
public class PaymentController {

    @Autowired
    private PaymentService paymentService;


    /**
     * 根据主键id查询对应数据
     *
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public Result<PaymentPo> getById(@PathVariable("id") Long id) {
        return Result.success(this.paymentService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param paymentPo
     * @return
     */
    @PostMapping("/insert")
    public Result<Boolean> insert(@RequestBody PaymentPo paymentPo) {
        int insert = this.paymentService.insert(paymentPo);
        return insert > 0 ? Result.success(Boolean.TRUE, "新增成功") : Result.success(Boolean.FALSE, "新增失败");
    }

}
